
<?php include_once(dirname(__FILE__) . '/../general/head.php'); ?>

<!-- header -->
<?php include_once(dirname(__FILE__) . '/../general/header.php'); ?>

<?php include_once('left.php'); ?>


<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header"><?php echo $title; ?></h1>
        </div>
    </div>

    <?php
    if($updateResult){
    ?>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-success">
                <div class="panel-heading">
                    <?php echo $updateResult; ?>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>
    <!-- /.row -->
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Thông tin tài khoản
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-6">
                            <form method="post" action="<?php echo site_url(get_folder($loggedUser['title']).'/account/update/' . $user_id); ?>">
                                <div>
                                    <?php echo validation_errors(); ?>
                                </div>
                                <div class="form-group <?php echo (form_error('name') != '' ? 'has-error' : ''); ?>">
                                    <label>Họ tên</label>

                                    <input class="form-control" type="text" name="name" value="<?php echo $user['name']; ?>" readonly="readonly"> 
                                    <?php print(form_error('name', '<label class="control-label" for="inputError">', '</label>')); ?>
                                </div>
                                <div class="form-group <?php echo (form_error('user_email') != '' ? 'has-error' : ''); ?>" >
                                    <label>Email</label>

                                    <input class="form-control" type="text" name="user_email" value="<?php echo $user['email']; ?>" readonly="readonly"> 
                                    <?php print(form_error('user_email', '<label class="control-label" for="inputError">', '</label>')); ?>
                                </div>
                                <div class="form-group <?php echo (form_error('username') != '' ? 'has-error' : ''); ?>">
                                    <label>Username</label>

                                    <input class="form-control" type="text" name="username" value="<?php echo $user['username']; ?>" readonly="readonly">
                                    <?php print(form_error('username', '<label class="control-label" for="inputError">', '</label>')); ?>
                                </div>
                                <div class="form-group <?php echo (form_error('user_password') != '' ? 'has-error' : ''); ?>">
                                    <label>Password (không bắt buộc)</label>

                                    <input class="form-control" type="password" name="user_password" autocomplete="off" > 
                                    <?php print(form_error('user_password', '<label class="control-label" for="inputError">', '</label>')); ?>
                                </div>
                                <div class="form-group <?php echo (form_error('confirm_password') != '' ? 'has-error' : ''); ?>" >
                                    <label>Xác nhận Password</label>

                                    <input class="form-control" type="password" name="confirm_password" autocomplete="off"> 
                                    <?php print(form_error('confirm_password', '<label class="control-label" for="inputError">', '</label>')); ?>
                                </div>
                                <?php if (false) { ?>
                                    <div class="form-group">
                                        <label>Credit</label>
                                        <input class="form-control" type="text" name="user_credit" value="<?php echo $user['credit']; ?>"  <?php
                                        if ($su == "0") {
                                            echo "readonly='readonly'";
                                        }
                                        ?> > 
                                    </div>

                                    <div class="form-group">
                                        <label>Group</label>
                                        <select name="user_group" class="form-control">
                                            <?php foreach ($allgroups as $key => $group) { ?>
                                                <?php if ($su == "1") { ?>						
                                                    <option <?php
                                                    if ($user['gid'] == $group['gid']) {
                                                        echo "selected";
                                                    }
                                                    ?> value="<?php echo $group['gid']; ?>"><?php echo $group['group_name']; ?></option>
                                                        <?php
                                                    } else {
                                                        if ($user['gid'] == $group['gid']) {
                                                            ?>
                                                        <option value="<?php echo $group['gid']; ?>"><?php echo $group['group_name']; ?></option>
                                                        <?php
                                                    }
                                                }
                                            }
                                            ?>
                                        </select>

                                    </div>
                                <?php } ?>
                                <?php
                                if ($su == "1") {
                                    ?>
                                    <tr>
                                        Account Type

                                    <select name="account_type">
                                        <option <?php
                                        if ($user['su'] == "0") {
                                            echo "selected";
                                        }
                                        ?> value="0">User</option>
                                        <option <?php
                                        if ($user['su'] == "1") {
                                            echo "selected";
                                        }
                                        ?> value="1">Administrator</option>
                                    </select>

                                    </tr>
                                    <?php
                                }
                                ?>
                                <br>
                                <input class="btn btn-primary" type="submit" value="Lưu thay đổi"> 
                            </form>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>


</div>
<!-- /#page-wrapper -->

<?php include_once(dirname(__FILE__) . '/../general/footer.php'); ?>